﻿@{
    ViewData["Title"] = "访问规则";
}

<div class="panel panel-default">
    <div class="form-content">
        <div class="form-body">
            <div id="toolbar" class="row" data-toggle="form" data-field="AccessRule" data-grid="#grid" data-filterable="true" data-size="4,5,7">
                <input data-field="code,resource.title" data-size="4,0,12" data-logic="or" data-operator="contains" />
                <button data-button="query"></button>
                <button data-button="clear">清除条件</button>
                <div class="pull-right" style="padding-right:15px;">
                    <button data-button="add" data-popup="Edit"></button>
                </div>
                <a data-button="advancedSearch" data-target="#filter_advancedSearch_grid"></a>
                <div id="filter_advancedSearch_grid" class="advancedSearch">
                    <div class="row">
                        <input data-field="code" data-label="规则编号" data-operator="contains" data-logic="or" />
                        <input data-field="resource.title" data-label="资源名称" data-operator="contains" data-logic="or" />
                        <input data-field="isAllow" data-label="是否允许" data-role="kendoDropDownList" data-data="#:cache.allowType" />
                    </div>
                    <div class="row">
                        <input data-field="identityType" data-label="授权对象类型" data-role="kendoDropDownList" data-data="#:cache.identityType" data-changed="#:IdentityType.onIdentityTypeChange" />
                        <input data-field="identityId" data-label="授权对象" type="hidden" />
                        <input data-field="identityName" data-label="授权对象" data-filterable="false" data-popup="SelectRole" data-popup-parameter="#:#_TemplatePopupParameter_SelectIdentity" />
                        <input data-field="condition" data-label="条件" data-operator="contains" data-logic="or" />
                    </div>
                </div>
            </div>
            <div id="grid" data-toggle="grid" data-form="#toolbar" node="grid" data-related='#_PopupAccessRuleDetail' data-dblclicking="#:IdentityType.onGridSelecting">
                <div node="columns" node-type="array">
                    <span data-field="code" data-title="规则编号"></span>
                    <span data-field="resource.name" data-title="资源" data-width="20%"></span>
                    <span data-field="identityType" data-title="授权对象类型" data-data-from="cache.identityType"></span>
                    <span data-field="isAllow" data-title="是否允许" data-data-from="cache.allowType"></span>
                    <span data-field="priority" data-title="优先级"></span>
                    <span data-field="accessCount" data-title="访问次数"></span>
                    <span data-field="limitAccessCount" data-title="访问次数限制"></span>
                    <span data-field="condition" data-title="条件" data-width="20%"></span>
                    <span data-field="expireTime" data-title="过期时间" data-type="datetime"></span>
                    <span data-field="state" data-title="状态" data-data-from="cache.dataState"></span>
                    <span data-field="createdOn" data-title="创建时间" data-type="datetime"></span>
                </div>
                <span node="dataSource">
                    <span node="transport">
                        <span node="read" data-url="/odata/AccessRules?$expand=resource($select=id,name)">
                        </span>
                    </span>
                    <span node="sort" data-field="code" data-dir="asc"></span>
                </span>
            </div>
        </div>
    </div>
</div>

<div id="_PopupAccessRuleDetail" data-toggle="popup" data-type="Detail" data-title="访问规则" data-size="large">
    <div class="popup-content" data-toggle="form" data-field="AccessRule" data-detailable="true">
        <div class="popup-body">
            <div class="form-content">
                <div class="form-body">
                    <span data-field="code" data-label="规则编号"></span>
                    <span data-field="resource.name" data-label="资源"></span>
                    <span data-field="identityType" data-label="授权对象类型" data-data-from="cache.identityType"></span>
                    <span data-field="identityName" data-label="授权对象"></span>
                    <span data-field="isAllow" data-label="是否允许" data-data-from="cache.allowType"></span>
                    <span data-field="priority" data-label="优先级"></span>
                    <span data-field="accessCount" data-label="访问次数"></span>
                    <span data-field="limitAccessCount" data-label="访问次数限制"></span>
                    <span data-field="expireTime" data-label="过期时间" data-formatter="#:$.com.dateFormatter"></span>
                    <span data-field="state" data-label="状态" data-data-from="cache.dataState"></span>
                    <span data-field="condition" data-label="条件"></span>
                </div>
            </div>
        </div>
        <div class="popup-footer text-right">
            <button data-button="edit" data-popup="Edit">编 辑</button>
            <button data-button="close">关 闭</button>
        </div>
    </div>
</div>

<div id="_PopupAccessRuleEdit" data-toggle="popup" data-type="Edit" data-title="访问规则" data-size="large" data-related="#toolbar" data-opened="#:IdentityType.onEditOpened">
    <div class="popup-content" data-toggle="form" data-field="AccessRule" data-editable="true" data-url="/api/AccessRules" data-size="12,3,8">
        <div class="popup-body">
            <div class="form-content">
                <div class="form-body">
                    <input data-field="code" data-label="规则编号" required data-size="12,3,4" />
                    <input data-field="resourceId" data-label="资源编号" type="hidden" />
                    <input data-field="resource.name" data-label="资源" data-popup="SelectResource" data-popup-parameter="#:#_TemplatePopupParameter_SelectResource" />
                    <span data-field="identityType" data-label="授权对象类型" required type="radio" data-with-group="true" data-data="#:cache.identityType" data-value="Role" data-changed="#:IdentityType.onIdentityTypeChange"></span>
                    <input data-field="identityId" data-label="授权对象" type="hidden" />
                    <input data-field="identityName" data-label="授权对象" data-popup="SelectRole" data-popup-parameter="#:#_TemplatePopupParameter_SelectIdentity" />
                    <span data-field="isAllow" data-label="是否允许" required type="radio" data-with-group="true" data-data="#:cache.allowType" data-value="Allow"></span>
                    <input data-field="priority" data-label="优先级" required data-size="12,3,4" data-role="kendoNumericTextBox" data-min="0" data-max="999" data-value="0" data-format="n0" />
                    <span data-field="accessCount" data-label="访问次数"></span>
                    <input data-field="limitAccessCount" data-label="访问次数限制" data-size="12,3,4" data-role="kendoNumericTextBox" data-min="0" data-max="99999999" data-value="0" data-format="n0" />
                    <input data-field="expireTime" data-label="过期时间" type="date" data-size="12,3,4" data-role="kendoDatePicker" data-formatter="#:$.com.dateFormatter" />
                    <span data-field="state" data-label="状态" required type="radio" data-with-group="true" data-data="#:cache.dataState" data-value="Available"></span>
                    <textarea data-field="condition" data-label="条件" rows="3" data-multiple="true"></textarea>
                </div>
            </div>
        </div>
        <div class="popup-footer text-right">
            <button data-button="post" data-success-text="新增成功">新 增</button>
            <button data-button="put" data-success-text="保存成功">提 交</button>
            <button data-button="delete" data-success-text="删除成功">删 除</button>
            <button data-button="close">关 闭</button>
        </div>
    </div>
</div>

<!--弹出框参数传递-->
<span id="_TemplatePopupParameter_SelectResource" node="popupParameter" data-title="选择资源">
    <span node="parameter" node-type="array">
        <span data-transfer="out" data-source="resourceId" data-target="id"></span>
        <span data-transfer="int,out" data-source="resource.name" data-target="name"></span>
    </span>
</span>

<span id="_TemplatePopupParameter_SelectIdentity" node="popupParameter">
    <span node="parameter" node-type="array">
        <span data-transfer="out" data-source="identityId" data-target="id"></span>
        <span data-transfer="int,out" data-source="identityName" data-target="alias"></span>
    </span>
</span>

<partial name="../Popups/SelectUser" />
<partial name="../Popups/SelectRole" />
<partial name="../Popups/SelectGroup" />
<partial name="../Popups/SelectLevel" />
<partial name="../Popups/SelectResource" />
<script src=~/js/identityType.js asp-append-version="true"></script>